using System;

using octalforty.Waffle.ComponentModel.Managers;

using octalforty.Waffle.ObjectModel.Business.Collections;

using octalforty.Waffle.Web.Engine.Web.UI;

namespace octalforty.Waffle.Web.UI.Views
{
    /// <summary>
    /// Default page which lists all forums.
    /// </summary>
    public partial class Default : Page, IForumManagerServiceDependency
    {
        #region Private Member Variables
        private IForumManagerService forumManagerService;
        private ForumCollection forums;
        #endregion

        /// <summary>
        /// Initializes a new instance of <see cref="Default"/> class.
        /// </summary>
        public Default()
        {
        }

        #region Page Members
        /// <summary>
        /// Initializes the model when the page is first requested and on all subsequent postbacks.
        /// </summary>
        protected override void InitializeModelEx()
        {
            base.InitializeModelEx();

            forums = ForumManagerService.GetForums();
        }

        /// <summary>
        /// Binds a data source to the invoked server control and all its child controls.
        /// </summary>
        ///
        public override void DataBind()
        {
            base.DataBind();

            forumList.Forums = forums;
            forumList.DataBind();
        }
        #endregion

        #region IForumManagerServiceDependency Members
        /// <summary>
        /// Gets or sets a reference to the <see cref="IForumManagerService" />.
        /// </summary>
        public IForumManagerService ForumManagerService
        {
            get { return forumManagerService; }
            set { forumManagerService = value; }
        }
        #endregion
    }
}
